import request from '@/utils/request'

export const queryByTopic = (topic, params) =>
  request({
    url: `online/authorization/message/topic/${topic}`,
    method: 'get',
    params
  })

export const queryReceived = (params) =>
  request({
    url: `online/authorization/message/received`,
    method: 'get',
    params
  })

export const readAll = (params) =>
  request({
    url: `online/authorization/message/read/all`,
    method: 'post',
    params
  })

export const unreadCount = (params) =>
  request({
    url: `online/authorization/message/unread/count`,
    method: 'get',
    params
  })


export const readMessage = (messageUuid) =>
  request({
    url: `online/authorization/message/${messageUuid}/read`,
    method: 'get'
  })


export const delMessage = (messageUuid) =>
  request({
    url: `online/authorization/message/${messageUuid}`,
    method: 'delete'
  })


export function delAllMessage(readed) {
  var url = 'online/authorization/message/delete/all'
  if(readed != undefined) {
    url = url + '?readed=' + readed
  }
  return request({
    url: url,
    method: 'delete',
  })
}


